// var Commons = require("webpack/lib/optimize/CommonsChunkPlugin");
// //压缩代码
// var uglifyJsPlugin = webpack.optimize.UglifyJsPlugin;
//生成CSS文件
// var E = require("extract-text-webpack-plugin");
//生成HTML
var html = require("html-webpack-plugin")
//删除文件
var clean = require('clean-webpack-plugin');

var webpack = require("webpack");

module.exports = {
	entry: './app/app.js',
	output: {
		path: __dirname+'/www',
		filename: 'js/main.js',
	},
	module:{
		loaders:[
			{
				test: /\.css$/,
				loader: 'style-loader!css-loader!less-loader'
			},
			{
				test: /\.(png|jpe?g|gif)$/,
				loader: 'url-loader?limit=10240&name=images/[name]-[hash:4].[ext]'
			},
			{
				test: /\.vue$/,
				loader: 'vue-loader'
			}
		]
	},
	plugins:[
		// new webpack.optimize.CommonsChunkPlugin({
		// 	name:"common"
		// }),
		// new E({
		// 	filename:"css/style.css",
		// 	allChunks:true//合并所有样式文件
		// }),
		new clean(["www"]),
		new html({
			title:"生活一家",
			template:__dirname+"/app/index.html",
			filename:"index.html",
			// chunks:["common",'bundle3']
		}),
		//设置全局变量
		new webpack.ProvidePlugin({
            // React: 'react',
            // ReactDOM: 'react-dom'
        })//直接加载到全局不需要require()
		// new webpack.optimize.UglifyJsPlugin({
		// 	compress: {
		//         warnings: false //取消报错提示
		//     }
		// })//压缩代码
	],
	// webpack-dev-server
	devServer: {
	  contentBase:"./www",
      inline: true,
      port: 8088
    },
	resolve:{           
        // root: __dirname+'/app/js',//require查找module的话从这里开始查找            
        // modules:[
        // 	"node_modules",
        // 	__dirname+'/app/js',
        // 	__dirname+'/app/images',
        // ],
        // extensions: ['.js', '.css',".less"],//require模块可以省略不写后缀名            
        alias: {//后续直接 require('style') 即可
        	'vue$': 'vue/dist/vue.common.js',
            // style : './css/style.css',
        }
    }
}